package jocl.samples;

import java.util.Arrays;

public class SequenceCalulation {

	public static void main(String[] args) {
		int n = 50000;
		float[] input = new float[n];
		float[] output = new float[n];
		
		long before = System.nanoTime();
		
		Arrays.fill(input, 1.123f);
		for ( int i = 0 ; i < n; i++) {
			output[i] = 0;
			for (int j = 0; j < n; j++) {
				output[i] += input[j];
			}
		}
		
		long after = System.nanoTime();
		
		float totalDurationMs = (after-before)/1e6f;
	    System.out.println("Total duration: "+totalDurationMs+"ms");
	    
	   
	    boolean result = true;
	    // print 10 first output results
	    for (int i = 0; i < n; i++) {
	    	if (output[i] != 56111.62f ) {
	    		result = false;
	    	}
	    }
	    System.out.print("...");
	    System.out.println(result ? "PASSED": "FAILED");
	}
	
}
